package com.ttai.presenter.activity;

import android.widget.Toast;

import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.ttai.model.net.OTPBean;
import com.ttai.model.net.ResponseInfo;
import com.ttai.presenter.base.BasePresenter;
import com.ttai.ui.activity.TaiId;

import retrofit2.Call;

public class OTPCreatePresenter extends BasePresenter{
    TaiId taiId;

    public OTPCreatePresenter(TaiId taiId) {
        this.taiId = taiId;
    }

    @Override
    protected void showError(String message) {
        Toast.makeText(taiId,message,Toast.LENGTH_SHORT).show();

    }

    @Override
    protected void parseJson(JsonObject json) {
        Gson gson = new Gson();
        OTPBean otpBean = gson.fromJson(json,OTPBean.class);

        taiId.getOTP(otpBean.getOtp());
    }
    public void crateOTP(String token,String cid,String accountFlag,String appId){
        Call<ResponseInfo> otpInfo = responseInfoApi.crateOTP(token, cid, accountFlag, appId);
        otpInfo.enqueue(new CallBackAdapter());
    }
}
